package storage

import (
	"fmt"
	"io"
	"os"
	"oss-api/boot"
)

// LocationStorage 本地源
type LocationStorage struct {
	Path string
}

func NewLocationStorage() *LocationStorage {
	storage := boot.Config.Storage.Location
	return &LocationStorage{
		Path: storage.Path,
	}
}

func (l *LocationStorage) CreateFolder(name string) (bool, error) {
	err := os.Mkdir(fmt.Sprintf("%s/%s", l.Path, name), os.ModePerm)
	if err != nil {
		return false, err
	}
	return true, nil
}

func (a *LocationStorage) UploadFile(name string, reader io.Reader) (string, error) {
	return "", nil
}

func (a *LocationStorage) DeleteResource(path ...string) error {
	return nil
}

func (a *LocationStorage) SetResourcePerm(path string, state bool) error {
	return nil
}
